package homework;

import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

/**
 * map的输出参数 key：使用LongWritable，因为支持排序，考虑map阶段会自动排序 value: 没有需要处理的逻辑
 */
public class SortMapper extends Mapper<LongWritable, Text, LongWritable, NullWritable> {

    LongWritable k = new LongWritable();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        // 每行只有一个数字
        long line = Long.parseLong(value.toString());
        k.set(line);

        context.write(k, NullWritable.get());
    }
}
